const state = () => ({
  content:[
    /*{
      type: "OPPO 专区",
      content: [//----以下命名与后台不一致，所以在html当中已经修改，该格式仅供参考
        {
          img: "https://dsfs.oppo.com/archives/202105/2021052010053360a5cf2d8a44e.png?_w_=1310&amp;_h_=950",
          comSerName: "Reno6",
          colorName: "星河入梦",
          price: 3999,
          comId: 1,
          proStatus: "新品"
        },
        {
          img: "https://dsfs.oppo.com/archives/202105/2021052010053360a5cf2d8a44e.png?_w_=1310&amp;_h_=950",
          comSerName: "Reno6",
          colorName: "星河入梦",
          price: 3999,
          comId: 1,
          proStatus: "新品"
        },
        {
          img: "https://dsfs.oppo.com/archives/202105/2021052010053360a5cf2d8a44e.png?_w_=1310&amp;_h_=950",
          comSerName: "Reno6",
          colorName: "星河入梦",
          price: 3999,
          comId: 1,
          proStatus: "新品"
        },
        {
          img: "https://dsfs.oppo.com/archives/202105/2021052010053360a5cf2d8a44e.png?_w_=1310&amp;_h_=950",
          comSerName: "Reno6",
          colorName: "星河入梦",
          price: 3999,
          comId: 1,
          proStatus: "新品"
        },
        {
          img: "https://dsfs.oppo.com/archives/202105/2021052010053360a5cf2d8a44e.png?_w_=1310&amp;_h_=950",
          comSerName: "Reno6",
          colorName: "星河入梦",
          price: 3999,
          comId: 1,
          proStatus: "新品"
        },
        {
          img: "https://dsfs.oppo.com/archives/202105/2021052010053360a5cf2d8a44e.png?_w_=1310&amp;_h_=950",
          comSerName: "Reno6",
          colorName: "星河入梦",
          price: 3999,
          comId: 1,
          proStatus: "新品"
        },
        {
          img: "https://dsfs.oppo.com/archives/202105/2021052010053360a5cf2d8a44e.png?_w_=1310&amp;_h_=950",
          comSerName: "Reno6",
          colorName: "星河入梦",
          price: 3999,
          comId: 1,
          proStatus: "新品"
        },
        {
          img: "https://dsfs.oppo.com/archives/202105/2021052010053360a5cf2d8a44e.png?_w_=1310&amp;_h_=950",
          comSerName: "Reno6",
          colorName: "星河入梦",
          price: 3999,
          comId: 1,
          proStatus: "新品"
        },
        {
          img: "https://dsfs.oppo.com/archives/202105/2021052010053360a5cf2d8a44e.png?_w_=1310&amp;_h_=950",
          comSerName: "Reno6",
          colorName: "星河入梦",
          price: 3999,
          comId: 1,
          proStatus: "新品"
        },
        {
          img: "https://dsfs.oppo.com/archives/202105/2021052010053360a5cf2d8a44e.png?_w_=1310&amp;_h_=950",
          comSerName: "Reno6",
          colorName: "星河入梦",
          price: 3999,
          comId: 1,
          proStatus: "新品"
        },
      ]
    },
    {
      type: "OPPO 专区",content: [
        {
          img: "https://dsfs.oppo.com/archives/202105/2021052010053360a5cf2d8a44e.png?_w_=1310&amp;_h_=950",
          comSerName: "Reno6",
          colorName: "星河入梦",
          price: 3999,
          comId: 1,
          proStatus: "新品"
        },
        {
          img: "https://dsfs.oppo.com/archives/202105/2021052010053360a5cf2d8a44e.png?_w_=1310&amp;_h_=950",
          comSerName: "Reno6",
          colorName: "星河入梦",
          price: 3999,
          comId: 1,
          proStatus: "新品"
        },
        {
          img: "https://dsfs.oppo.com/archives/202105/2021052010053360a5cf2d8a44e.png?_w_=1310&amp;_h_=950",
          comSerName: "Reno6",
          colorName: "星河入梦",
          price: 3999,
          comId: 1,
          proStatus: "新品"
        },
      ]
    }*/
  ]
})

const getters = {
  getData(state){
    return state.content;
  },
  refreshPreShowSessionStorageData(state){
    sessionStorage.setItem("PreShow",JSON.stringify(state.content));
  }
}

const actions = {
  loadDataForProShow({commit},payload){//对商品展示添加最基础的数据
    commit("loadDataForProShowMut",payload)
  },
  addDataForPreShowBySessionStorage({commit}){//重session中取出数据添加
    commit("addDataForPreShowBySessionStorageMut")
  }
}

const mutations = {
  loadDataForProShowMut(state,val){//对商品展示添加最基础的数据
    state.content = [...val];
  },
  addDataForPreShowBySessionStorageMut(state){
    state.content = [...JSON.parse(sessionStorage.getItem("PreShow"))]
  }
}

export default {
  namespaced: true,
  state,
  getters,
  actions,
  mutations
}
